#coding:utf-8
import csv
import time
#将获取的销量数据写入csv文件
#内容包括爬取时间及销量
#文件名是商品的id
class Output(object):
    def __init__(self,itemID,sellcount):
        self.itemID = itemID
        self.sellcount = sellcount
    
    def outputdata(self):
        with open('output/'+self.itemID+'.csv','ab+') as f:
             spamwriter = csv.writer(f,dialect='excel')
             now_time = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
             spamwriter.writerow([now_time, self.sellcount])

'''
spider = TBSpider("https://detail.m.tmall.com/item.htm?id=560090110694&sku_properties=1627207:28338")
out = Output(spider.getItemID(),spider.getCount())
out.outputdata()
'''
